package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallCollect;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallCollectMapper {
    @Delete({
        "delete from haogoumall_collect",
        "where collect_id = #{collectId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer collectId);

    @Insert({
        "insert into haogoumall_collect (collect_id, user_id, ",
        "collect_value_id, collect_type, ",
        "collect_add_time, collect_update_time, ",
        "collect_deleted)",
        "values (#{collectId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, ",
        "#{collectValueId,jdbcType=INTEGER}, #{collectType,jdbcType=TINYINT}, ",
        "#{collectAddTime,jdbcType=TIMESTAMP}, #{collectUpdateTime,jdbcType=TIMESTAMP}, ",
        "#{collectDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallCollect record);

    @InsertProvider(type=HaogoumallCollectSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallCollect record);

    @Select({
        "select",
        "collect_id, user_id, collect_value_id, collect_type, collect_add_time, collect_update_time, ",
        "collect_deleted",
        "from haogoumall_collect",
        "where collect_id = #{collectId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="collect_id", property="collectId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="collect_value_id", property="collectValueId", jdbcType=JdbcType.INTEGER),
        @Result(column="collect_type", property="collectType", jdbcType=JdbcType.TINYINT),
        @Result(column="collect_add_time", property="collectAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="collect_update_time", property="collectUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="collect_deleted", property="collectDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallCollect selectByPrimaryKey(Integer collectId);

    @UpdateProvider(type=HaogoumallCollectSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallCollect record);

    @Update({
        "update haogoumall_collect",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "collect_value_id = #{collectValueId,jdbcType=INTEGER},",
          "collect_type = #{collectType,jdbcType=TINYINT},",
          "collect_add_time = #{collectAddTime,jdbcType=TIMESTAMP},",
          "collect_update_time = #{collectUpdateTime,jdbcType=TIMESTAMP},",
          "collect_deleted = #{collectDeleted,jdbcType=BIT}",
        "where collect_id = #{collectId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallCollect record);
}